from datetime import datetime

from db import db


class UserImage(db.Model):
    # 设置表名
    __tablename__ = 't_user_image'

    # 创建数据库表字段
    # db.Column(类型，约束)
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    uid = db.Column(db.String(50), nullable=False)
    save_path = db.Column(db.String(255), nullable=False)
    is_wallpaper = db.Column(db.Boolean, default=False)
    is_deleted = db.Column(db.Boolean, default=False)
    created_time = db.Column(db.DateTime, default=datetime.utcnow)
    updated_time = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)

    def __repr__(self):
        return '<ImageInfo {self.name}>'
